Security MEDIUM : Staking requestUnstake silent overwrite restarts cooldown#12
Open
philpof102-svg wants to merge 2 commits into
Open
Security MEDIUM : Staking requestUnstake silent overwrite restarts cooldown#12philpof102-svg wants to merge 2 commits into
philpof102-svg wants to merge 2 commits into
Conversation
added 2 commits
June 4, 2026 01:31
GitlawbStaking.requestUnstake() silently overwrote unstakeRequestAt and
unstakeAmount when called while a pending request already existed. Two
real failure modes :
1. UX foot-gun : user re-requests with the same amount, accidentally
restarting the 7-day cooldown. Effectively a 14-day wait for what
they thought was the same operation.
2. Inconsistency vs NodeStaking : GitlawbNodeStaking.requestUnstake
reverts with UnstakePending() in the same scenario. The two staking
surfaces should behave the same to avoid integrator confusion and
ambiguous front-end logic.
Fix : add the UnstakePending() error and revert if unstakeRequestAt != 0.
Mirrors NodeStaking exactly. Users who want to cancel-and-resubmit
will need an explicit cancelUnstake() — tracked as a separate UX
improvement (out of scope for this minimal correctness fix).
Suggested regression test (Foundry) :
function test_RequestUnstake_Reverts_WhenPending() public {
token.approve(address(staking), 10_000e18);
staking.stake(10_000e18);
staking.requestUnstake(5_000e18);
vm.expectRevert(GitlawbStaking.UnstakePending.selector);
staking.requestUnstake(3_000e18); // would silently overwrite
}
Backward compatible at storage level — no struct changes. Behavior
change is intentional and improves safety.
Related to PR Gitlawb#12 bug report.
Author
|
Upgraded with merge-ready fix ( if (info.unstakeRequestAt != 0) revert UnstakePending();Mirrors Regression test (Foundry) function test_RequestUnstake_Reverts_WhenPending() public {
token.approve(address(staking), 10_000e18);
staking.stake(10_000e18);
staking.requestUnstake(5_000e18);
vm.expectRevert(GitlawbStaking.UnstakePending.selector);
staking.requestUnstake(3_000e18);
}Users who want to cancel and resubmit will need an explicit |
This was referenced Jun 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GitlawbStaking.requestUnstake silently overwrites a pending request, restarting the 7-day cooldown. Inconsistent with GitlawbNodeStaking which guards with
if (n.unstakeRequestAt != 0) revert UnstakePending();.Phishing/UI bug surface : attacker tricks user into signing requestUnstake(1) near end of their original cooldown → user loses their 1M unstake intent + restarts cooldown.
Fix : add the same guard from NodeStaking. One-line change.
8th PR in continuous Gitlawb audit. Related : #5, #6, #7, #8, #9, #10, #11. Reporter @philpof102-svg.